Skip to content

test(ci): harden Karma browser tests against launch flakiness under allTests#705

Merged
michalharakal merged 1 commit into
developfrom
ci/browser-test-karma-launch-resilience
Jun 7, 2026
Merged

test(ci): harden Karma browser tests against launch flakiness under allTests#705
michalharakal merged 1 commit into
developfrom
ci/browser-test-karma-launch-resilience

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Problem

allTests (run on every CI PR/push, and locally) intermittently fails a browser test with:

Errors occurred during launch of browser for testing. - ChromeHeadless
> ...the test task did not discover any tests to execute.

This surfaced as :skainet-data:skainet-data-api:wasmJsBrowserTest failing during a full allTests run, while the same task passes every time in isolation.

Root cause

Not a test bug — a flaky browser launch under concurrency. allTests starts ~20 wasmJs/js *BrowserTest tasks at once, each spinning up its own ChromeHeadless. On a loaded machine a browser exceeds Karma's default capture/activity timeouts (Disconnected, no message in 30000 ms / ChromeHeadless was not killed), Karma drops it, reports zero discovered tests, and Gradle fails the build on its failOnNoDiscoveredTests check. CI is the worst case for this: ubuntu-latest, -Xmx4g, and PRs run clean assemble allTests so every browser test re-executes from scratch.

Fix

Add a karma.config.d/skainet-browser-resilience.js to every browser-test module (the Kotlin Gradle plugin merges these into the generated karma.conf.js). It raises the capture/disconnect/no-activity timeouts and adds disconnect tolerance, so a CPU-starved browser is waited on instead of abandoned:

config.set({
    captureTimeout: 120000,
    browserDisconnectTimeout: 30000,
    browserDisconnectTolerance: 3,
    browserNoActivityTimeout: 120000,
    pingTimeout: 120000,
});

These knobs are not exposed by Kotlin's useKarma {} Gradle DSL, so a karma.config.d/*.js file is the supported way to set them. Applied across all browser modules (23 files) so the flakiness can't simply hop to a different module on the next run.

Verification

./gradlew allTests --rerun-tasks — forced every test task (incl. all browser tasks) to actually re-execute concurrently rather than hit the cache. BUILD SUCCESSFUL in 2m41s, no failures, no "did not discover any tests", no browser launch errors.

🤖 Generated with Claude Code

…llTests

During `allTests` (run on every CI PR/push) ~20 wasmJs/js *BrowserTest tasks
each start a ChromeHeadless instance concurrently. On a loaded machine a browser
can exceed Karma's default capture/activity timeouts and get dropped
("Disconnected, no message in 30000 ms" / "ChromeHeadless was not killed"),
after which Karma discovers zero tests and Gradle fails the build on its
`failOnNoDiscoveredTests` check -- even though the tests pass in isolation.
This surfaced as :skainet-data:skainet-data-api:wasmJsBrowserTest failing.

Add a karma.config.d/skainet-browser-resilience.js to every browser-test module
(merged into karma.conf.js by the Kotlin Gradle plugin) that raises the
capture/disconnect/no-activity timeouts and adds disconnect tolerance, so a
CPU-starved browser is waited on instead of abandoned. Applied across all
browser modules so the flakiness can't simply hop to a different one.

Verified: `./gradlew allTests --rerun-tasks` green (all browser tasks
re-executed concurrently, 2m41s).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully for this PR.

Generated Files:

  • Operator documentation: docs/modules/operators/_generated_/
  • JSON schema output: operators.json

Artifacts:

  • Download the documentation-preview-705 artifact to view the complete documentation locally.

This comment will be updated automatically when the PR is updated.

@michalharakal michalharakal merged commit 419b0c6 into develop Jun 7, 2026
10 checks passed
@michalharakal michalharakal deleted the ci/browser-test-karma-launch-resilience branch June 7, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant